package com.systop.servlet;

import com.systop.entity.Comment;
import com.systop.entity.Message;
import com.systop.service.CommentService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

public class CommentListServlet extends HttpServlet {
    private CommentService commentService =new CommentService();
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String mid = request.getParameter("mid");
        ArrayList<Comment> commentList = commentService.findAllByMsgId(Integer.parseInt(mid));
        request.setAttribute("commentList",commentList);
        request.getRequestDispatcher("comment/list.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
